<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Register</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
        }

        .register-container {
            background-color: #ffffff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        h2 {
            font-size: 24px;
        }

        input[type="text"], input[type="password"], input[type="email"] {
            width: 90%;
            padding: 10px;
            margin: 8px auto;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        button {
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 3px;
            padding: 10px 20px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        .login-link {
            margin-top: 10px;
        }
    </style>

    <script>
    document.addEventListener("DOMContentLoaded", function () {
        const passwordField = document.getElementById("password");
        const confirmPasswordField = document.getElementById("confirm_password");

        confirmPasswordField.addEventListener("input", function () {
            const password = passwordField.value;
            const confirmPassword = confirmPasswordField.value;

            if (password === confirmPassword) {
                confirmPasswordField.setCustomValidity("");
            } else {
                confirmPasswordField.setCustomValidity("Passwords do not match");
            }
        });
    });
</script>


</head>
<body>
    <div class="register-container">
        <h2>Register</h2>
        <form action="" method="post">
            {% csrf_token %}
            <input type="text" name="username" placeholder="Username" required>
            <input type="email" name="email" placeholder="Email" required>
            <input type="password" name="password" id="password" placeholder="Password" required>
            <input type="password" name="confirm_password" id="confirm_password" placeholder="Confirm Password" required>
            <button type="submit">Register</button>
        </form>
        <div class="login-link">
            <a href="/login">Already have an account? Login here</a>
        </div>
    </div>
</body>
</html>
